import 'dart:convert' show json;

import 'package:loxen/mode/mine/mine_information_mode.dart';


T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }

  return null;
}

class MineInfoData {
  MineInfoData({
    this.code,
    this.data,
  });

  factory MineInfoData.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : MineInfoData(
          code: asT<int>(jsonRes['code']),
          data: Data.fromJson(asT<Map<String, dynamic>>(jsonRes['data'])),
        );

  int code;
  Data data;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'code': code,
        'data': data,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}

class Data {
  Data({
    this.results,
  });

  factory Data.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : Data(
          results: MineInformation.fromJson(
              asT<Map<String, dynamic>>(jsonRes['results'])),
        );

  MineInformation results;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'results': results,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}
